package com.hz.erp.constant;

import com.hz.erp.enums.RetCode;

/**
 * @author 柯鑫
 * @ClassName com.hz.erp.constant.RetResponse
 * @description 将结果转换为封装后的对象
 * @create 2020年06月04日 14:34
 */
public class RetResponse {

    private final static String SUCCESS_MSG = "success";
    private final static String FAIL_MSG = "fail";

    public static <T> RetResult<T> makeOKRsp() {
        return new RetResult<T>().setCode(RetCode.SUCCESS).setMsg(SUCCESS_MSG);
    }

    public static <T> RetResult<T> makeOKRsp(T data) {
        return new RetResult<T>().setCode(RetCode.SUCCESS).setMsg(SUCCESS_MSG).setData(data);
    }

    public static <T> RetResult<T> makeErrRsp(String message) {
        return new RetResult<T>().setCode(RetCode.INTERNAL_SERVER_ERROR).setMsg(message);
    }

    public static <T> RetResult<T> makeRsp(int code, String msg) {
        return new RetResult<T>().setCode(code).setMsg(msg);
    }

    public static <T> RetResult<T> makeRsp(int code, String msg, T data) {
        return new RetResult<T>().setCode(code).setMsg(msg).setData(data);
    }

}
